package com.dcrzl.gazgmh.module.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.dcrzl.gazgmh.common.entity.sys.SysLog;
import com.dcrzl.gazgmh.common.mapper.sys.SysLogMapper;
import com.dcrzl.gazgmh.common.service.impl.BaseServiceImpl;
import com.dcrzl.gazgmh.common.utils.PageInfo;
import com.dcrzl.gazgmh.common.utils.Result;
import com.dcrzl.gazgmh.common.utils.SysConstant;
import com.dcrzl.gazgmh.module.sys.service.SysLogService;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

@Service("sysLogService")
public class SysLogServiceImpl extends BaseServiceImpl<SysLogMapper, SysLog> implements SysLogService {


    @Override
    public Result<SysLog> selectOne(SysLog sysLog) {
        LambdaQueryWrapper<SysLog> wrapper = new LambdaQueryWrapper<>();
        return super.selectOne(wrapper);
    }

    @Override
    public Result<List<SysLog>> selectList(SysLog sysLog) {
        LambdaQueryWrapper<SysLog> wrapper = new LambdaQueryWrapper<>();
        return super.selectList(wrapper);
    }

    @Override
    public PageInfo<SysLog> selectPage(SysLog sysLog) {
        LambdaQueryWrapper<SysLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Objects.nonNull(sysLog.getType()), SysLog::getType, sysLog.getType());
        return super.selectPage(sysLog, wrapper);
    }

    @Override
    public Result<Integer> removeById(Serializable id) {
        SysLog sysLog = new SysLog().setStatus(SysConstant.DATA_DELETE_STATUS)
                .setId((Long) id);
        return this.updateById(sysLog);
    }

}